﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace search
{
	/// <summary>
	/// Article 的摘要说明。
	/// </summary>
	public partial class BibleTools : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面

			if(Request["title"] == null || Request["title"].ToString() == "")
				return;

			if(Request["c"] == null || Request["c"].ToString() == "")
				return;

			if(Request["s"] == null || Request["s"].ToString() == "")
				return;

			this.Label_Title.Text = BibleTitle();

			if(!Page.IsPostBack)
			{
				DataSet ds = BibleToolsDataAccess.GetBibleContent(Request["title"].ToString(),
					Convert.ToInt32(Request["c"].ToString()), Convert.ToInt32(Request["s"].ToString()),
					Convert.ToInt32(Request["c1"].ToString()), Convert.ToInt32(Request["s1"].ToString()));

				this.Repeater1.DataSource = ds.Tables[0].DefaultView;
				this.Repeater1.DataBind();
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Repeater1.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.Repeater1_ItemDataBound);

		}
		#endregion

		public string BibleTitle()
		{
			return Request["title"].ToString() + "&nbsp;&nbsp;" + Request["c"].ToString() + "∶" + Request["s"].ToString() + "&nbsp;—&nbsp;" + 
				Request["c1"].ToString() + "∶" + Request["s1"].ToString();
		}

		private void Repeater1_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
		{
			if(e.Item.ItemIndex < 0)
				return;

			DataRowView drv = (DataRowView)e.Item.DataItem;
			Literal objLiteral1 = (Literal)e.Item.FindControl("Literal1");
			objLiteral1.Text = drv.Row["Content_Chap"].ToString() + "∶" + drv.Row["Content_Sec"].ToString() + "&nbsp;&nbsp;" + 
				drv.Row["Content_CN"].ToString();

			Literal objLiteral2 = (Literal)e.Item.FindControl("Literal2");
			objLiteral2.Text = drv.Row["Content_Chap"].ToString() + "∶" + drv.Row["Content_Sec"].ToString() + "&nbsp;&nbsp;" + 
				drv.Row["Content_EN"].ToString();

		}
	}
}
